home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / sbin / lm-syslog-setup < prev    next >
Encoding:
Text File  |  2006-12-06  |  2.6 KB  |  85 lines

  1. #! /bin/bash
  2.  
  3. set -e
  4.  
  5. if [ ! -f /etc/laptop-mode/laptop-mode.conf -o ! -f /usr/sbin/laptop_mode ] ; then
  6.   echo Laptop mode does not seem to be installed.
  7.   exit 1
  8. fi
  9.  
  10. . /usr/sbin/laptop_mode readconfig
  11.  
  12. if [ ! -f $SYSLOG_CONF ] ; then
  13.   echo Syslog configuration file \"$SYSLOG_CONF\" not found. 
  14.   echo Please configure the correct path in /etc/laptop-mode/laptop-mode.conf.
  15.   exit 1
  16. fi
  17.  
  18. echo This script helps you to set up separate syslog.conf files for the
  19. echo various modes a laptop can be in. Switching between the configurations
  20. echo is managed by the Laptop Mode Tools. While laptop mode is enabled, your
  21. echo original syslog.conf will be saved with with the .no-lm extension, i.e.
  22. echo it will be called $SYSLOG_CONF.no-lm. While laptop mode is NOT enabled,
  23. echo your syslog.conf will be as normal.
  24. echo
  25.  
  26. if [ "`readlink $SYSLOG_CONF`" != "" ] ; then
  27.   echo $SYSLOG_CONF already seems to be symlinked. Either lm-syslog-setup
  28.   echo has already been called, or some other program manages the syslog.conf
  29.   echo symlink. This script will not continue, for safety reasons.
  30.   exit 1
  31. fi
  32.  
  33. echo Creating config files:
  34. echo
  35. echo -n AC power, laptop mode off: $NOLM_AC_SYSLOG_CONF
  36. if [ -f "$NOLM_AC_SYSLOG_CONF" ] ; then
  37.   echo " (exists)"
  38. else
  39.   if ( cp -a "$SYSLOG_CONF" "$NOLM_AC_SYSLOG_CONF" ) ; then
  40.     echo " (created)"
  41.   else
  42.     echo " (creation failed, exiting)"
  43.     exit 1
  44.   fi
  45. fi
  46. echo -n AC power, laptop mode on: $LM_AC_SYSLOG_CONF
  47. if [ -f "$LM_AC_SYSLOG_CONF" ] ; then
  48.   echo " (exists)"
  49. else
  50.   if ( cp -a "$SYSLOG_CONF" "$LM_AC_SYSLOG_CONF" ) ; then
  51.     echo " (created)"
  52.   else
  53.     echo " (creation failed, exiting)"
  54.     exit 1
  55.   fi
  56. fi
  57. echo -n Battery power: $BATT_SYSLOG_CONF
  58. if [ -f "$BATT_SYSLOG_CONF" ] ; then
  59.   echo " (exists)"
  60. else
  61.   if ( cp -a "$SYSLOG_CONF" "$BATT_SYSLOG_CONF" ) ; then
  62.     echo " (created)"
  63.   else
  64.     echo " (creation failed, exiting)"
  65.     exit 1
  66.   fi
  67. fi
  68. echo
  69. while [ "$DO_ENABLE" != "y" -a "$DO_ENABLE" != "n" ] ; do
  70.   echo -n "Do you wish to enable the split configuration now? (y/n) "
  71.   read DO_ENABLE
  72. done
  73. if [ "$DO_ENABLE" == "y" ] ; then
  74.   sed -i /etc/laptop-mode/laptop-mode.conf -e "s/DO_SYSLOG=0/DO_SYSLOG=1/"
  75.   sed -i /etc/laptop-mode/laptop-mode.conf -e "s/CONTROL_SYSLOG_CONF=0/CONTROL_SYSLOG_CONF=1/"
  76.   if ( ! grep DO_SYSLOG=1 /etc/laptop-mode/laptop-mode.conf ) && ( ! grep CONTROL_SYSLOG_CONF=1 /etc/laptop-mode/laptop-mode.conf ) ; then
  77.     echo Enabling the split configuration failed.
  78.     exit 1
  79.   else
  80.     echo Enabling the split configuration succeeded.
  81.     echo Restarting laptop mode to activate changes.
  82.     /usr/sbin/laptop_mode auto force
  83.   fi
  84. fi
  85.